﻿//import { signalR } from "../lib/aspnet/signalr/dist/browser/signalr.js";
let connection = null;


setupConnection = () => {
    connection = new signalR.HubConnectionBuilder()
        .withUrl("/signalr", {
            skipNegotiation: true,
            transport: signalR.HttpTransportType.WebSockets})
        .build();
    connection.start().catch(err => console.error(err.toString()));

    
}

setupConnection();

document.getElementById("submit").addEventListener("click", e => {
    connection.invoke("SendMessage", { message: "123" }).catch(
        err => console.log(err)
)
})

connection.on("getMessage", (update) => {
        const resultdiv = document.getElementById("result");
        resultdiv.innerHTML = update;
    });